const {ccclass, property} = cc._decorator;

@ccclass
export default class dynamicLoadSprite extends cc.Component {

    // LIFE-CYCLE CALLBACKS:

    @property(cc.Prefab)
    pre: cc.Prefab = null;

    @property(cc.SpriteFrame)
    sp:cc.SpriteFrame

    onLoad () {
        
    }

    start () {
        cc.resources.load("sprite/npc", cc.SpriteFrame,  (err, spriteFrame)=> {
            console.log(spriteFrame);
            console.log(this.sp);
            
            this.node.addComponent(cc.Sprite);
            this.node.getComponent(cc.Sprite).spriteFrame = spriteFrame;
        });
        cc.resources.load("prefab/tt", cc.Prefab,   (err, prefab) => {
            var newNode = cc.instantiate(prefab);
            
            newNode.parent = this.node;
        });
    }

    // update (dt) {}
}
